/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package general.converters;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;
import jpa.controller.EtapaJpaController;
import jpa.entity.Etapa;
/**
 *
 * @author isaias
 */
@FacesConverter(value="etapaConverter")
public class EtapaConverter implements Converter {
    public Object getAsObject(FacesContext fc, UIComponent uic, String name) {
         Etapa etapa = new EtapaJpaController().findCidadeByName(name);
        return etapa;
    }

    public String getAsString(FacesContext fc, UIComponent uic, Object o) {

        if(o instanceof Etapa){
           return ((Etapa)o).getName();
        }

        return null;
    }
}
